#include <iostream>
#include <string>
#include <cmath>
#include <unordered_map>

bool isPrime(int num) {
    if (num < 2) {
        return false;
    }
    for (int i = 2; i <= sqrt(num); i++) {
        if (num % i == 0) {
            return false;
        }
    }
    return true;
}

int findNextPrime(int num) {
    while (true) {
        if (isPrime(num)) {
            return num;
        }
        num++;
    }
}

int wordToNumber(std::string word) {
    std::unordered_map<std::string, int> numbers = {
        {"zero", 0}, {"one", 1}, {"two", 2}, {"three", 3}, {"four", 4},
        {"five", 5}, {"six", 6}, {"seven", 7}, {"eight", 8}, {"nine", 9}
    };
    return numbers[word];
}

int main() {
    std::string input;
    std::cout;
    std::getline(std::cin, input);
    
    std::string word;
    int num = 0;
    for (int i = 0; i < 3; i++) {
        word = input.substr(i * 5, 4);
        int number = wordToNumber(word);
        if (number == 0 && word != "zero") {
            std::cout << "Wrong input" << std::endl;
            return 0;
        }
        num = num * 10 + number;
    }

    if (100 <= num && num <= 999) {
        int result = findNextPrime(num);
        std::cout << result << std::endl;
    } else {
        std::cout << "Wrong input" << std::endl;
    }

    return 0;
}
